106B - Choosing Laptop - CodeForces Solution


brute force implementation *1000

Please click on ads to support us..

Python Code:


tests = int(input())
laptops = []
for i in range(1, tests + 1):
    speed, ram, hdd, cost = [int(x) for x in input().split()]
    laptops.append((cost, i, speed, ram, hdd))

outdated = set()
for k, (c, i, s, r, h) in enumerate(laptops):
    for l, (cc, ii, ss, rr, hh) in enumerate(laptops):
        if k != l:
            if s < ss and r < rr and h < hh:
                outdated.add((c, i, s, r, h))

resu = []
for l in laptops:
    if l not in outdated:
        resu.append(l)

resu = sorted(resu)

print(resu[0][1])

C++ Code:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
int main () {
    std::ios::sync_with_stdio(NULL);cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ll n,m=1001,ans;
    cin>>n;
    ll a[n],b[n],c[n],x[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i]>>x[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(a[i]<a[j]&&b[i]<b[j]&&c[i]<c[j]){
                x[i]=1001;
                break;
            }
        }
    }
    for(int i=0;i<n;i++){
        if(x[i]<m){
            m=x[i];
            ans=i+1;
        }
    }
    cout<<ans;
}


Comments

Submit
0 Comments
More Questions

838A - Binary Blocks
1515D - Phoenix and Socks
1624D - Palindromes Coloring
1552F - Telepanting
1692G - 2Sort
1191A - Tokitsukaze and Enhancement
903A - Hungry Student Problem
52B - Right Triangles
1712A - Wonderful Permutation
1712D - Empty Graph
1712B - Woeful Permutation
1712C - Sort Zero
1028B - Unnatural Conditions
735B - Urbanization
746C - Tram
1278B - A and B
1353D - Constructing the Array
1269C - Long Beautiful Integer
1076A - Minimizing the String
913C - Party Lemonade
1313A - Fast Food Restaurant
681A - A Good Contest
1585F - Non-equal Neighbours
747A - Display Size
285A - Slightly Decreasing Permutations
515C - Drazil and Factorial
1151E - Number of Components
1151F - Sonya and Informatics
556A - Case of the Zeros and Ones
867A - Between the Offices